package com.example.app;

import android.os.Bundle;

import com.example.sample.util.MPermissionDelegate;
import com.umeng.analytics.MobclickAgent;

import net.liteheaven.xblib.common.log.XLog;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;

public class BaseActivity extends AppCompatActivity {

	static {
		AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
	}
	
	protected final String TAG = getClass().getName();
	private MPermissionDelegate permissionDelegate = new MPermissionDelegate(this);

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		XLog.i(TAG, "onCreate");
	}

	@Override
	protected void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}

	@Override
	public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
		super.onRequestPermissionsResult(requestCode, permissions, grantResults);
		permissionDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
	}

	public void checkPermissions(String [] permissions, MPermissionDelegate.PermissionResultCallback callback){
		permissionDelegate.checkPermissions(permissions, callback);
	}
}
